<!doctype html>
<html lang="en" data-color-mode="dark">
<head>
<meta charset="utf-8">
<title>Vim 备忘清单
 &#x26;  vim cheatsheet &#x26;  Quick Reference</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta description="Vim 备忘清单
===

Vim 8.2 快速参考备忘单的有用集合，可帮助您更快地学习 vim 编辑器。

入门，为开发人员分享快速参考备忘单。">
<meta keywords="vim,reference,Quick,Reference,cheatsheet,cheat,sheet">
<link rel="icon" href="data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20height%3D%221em%22%20width%3D%221em%22%3E%20%3Cpath%20d%3D%22m21.66%2010.44-.98%204.18c-.84%203.61-2.5%205.07-5.62%204.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2%201.17-2.42%203.16-3.07%206.5-2.28l1.67.39c4.19.98%205.47%203.05%204.49%207.23Z%22%20fill%3D%22%23c9d1d9%22%2F%3E%20%3Cpath%20d%3D%22M15.06%2019.39c-.62.42-1.4.77-2.35%201.08l-1.58.52c-3.97%201.28-6.06.21-7.35-3.76L2.5%2013.28c-1.28-3.97-.22-6.07%203.75-7.35l1.58-.52c.41-.13.8-.24%201.17-.31-.3.61-.54%201.35-.74%202.2l-.98%204.19c-.98%204.18.31%206.24%204.48%207.23l1.68.4c.58.14%201.12.23%201.62.27Zm2.43-8.88c-.06%200-.12-.01-.19-.02l-4.85-1.23a.75.75%200%200%201%20.37-1.45l4.85%201.23a.748.748%200%200%201-.18%201.47Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3Cpath%20d%3D%22M14.56%2013.89c-.06%200-.12-.01-.19-.02l-2.91-.74a.75.75%200%200%201%20.37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z%22%20fill%3D%22%23228e6c%22%20%2F%3E%20%3C%2Fsvg%3E" type="image/svg+xml">
<link rel="stylesheet" href="..\style\style.css">
<link rel="stylesheet" href="..\style\katex.css">
</head>
<body><nav class="header-nav"><div class="max-container"><a href="..\index.html" class="logo"><svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" height="1em" width="1em">
  <path d="m21.66 10.44-.98 4.18c-.84 3.61-2.5 5.07-5.62 4.77-.5-.04-1.04-.13-1.62-.27l-1.68-.4c-4.17-.99-5.46-3.05-4.48-7.23l.98-4.19c.2-.85.44-1.59.74-2.2 1.17-2.42 3.16-3.07 6.5-2.28l1.67.39c4.19.98 5.47 3.05 4.49 7.23Z" fill="#c9d1d9"></path>
  <path d="M15.06 19.39c-.62.42-1.4.77-2.35 1.08l-1.58.52c-3.97 1.28-6.06.21-7.35-3.76L2.5 13.28c-1.28-3.97-.22-6.07 3.75-7.35l1.58-.52c.41-.13.8-.24 1.17-.31-.3.61-.54 1.35-.74 2.2l-.98 4.19c-.98 4.18.31 6.24 4.48 7.23l1.68.4c.58.14 1.12.23 1.62.27Zm2.43-8.88c-.06 0-.12-.01-.19-.02l-4.85-1.23a.75.75 0 0 1 .37-1.45l4.85 1.23a.748.748 0 0 1-.18 1.47Z" fill="#228e6c"></path>
  <path d="M14.56 13.89c-.06 0-.12-.01-.19-.02l-2.91-.74a.75.75 0 0 1 .37-1.45l2.91.74c.4.1.64.51.54.91-.08.34-.38.56-.72.56Z" fill="#228e6c"></path>
</svg>
<span class="title">Quick Reference</span></a><div class="menu"><a href="javascript:void(0);" class="searchbtn" id="searchbtn"><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
  <path fill="currentColor" d="M17.71,16.29 L14.31,12.9 C15.4069846,11.5024547 16.0022094,9.77665502 16,8 C16,3.581722 12.418278,0 8,0 C3.581722,0 0,3.581722 0,8 C0,12.418278 3.581722,16 8,16 C9.77665502,16.0022094 11.5024547,15.4069846 12.9,14.31 L16.29,17.71 C16.4777666,17.8993127 16.7333625,18.0057983 17,18.0057983 C17.2666375,18.0057983 17.5222334,17.8993127 17.71,17.71 C17.8993127,17.5222334 18.0057983,17.2666375 18.0057983,17 C18.0057983,16.7333625 17.8993127,16.4777666 17.71,16.29 Z M2,8 C2,4.6862915 4.6862915,2 8,2 C11.3137085,2 14,4.6862915 14,8 C14,11.3137085 11.3137085,14 8,14 C4.6862915,14 2,11.3137085 2,8 Z"></path>
</svg><span>搜索</span><span>⌘K</span></a><a href="https://github.com/jaywcjlove/reference/blob/main/docs/vim.md" class="" target="__blank"><svg viewBox="0 0 36 36" fill="currentColor" height="1em" width="1em"><path d="m33 6.4-3.7-3.7a1.71 1.71 0 0 0-2.36 0L23.65 6H6a2 2 0 0 0-2 2v22a2 2 0 0 0 2 2h22a2 2 0 0 0 2-2V11.76l3-3a1.67 1.67 0 0 0 0-2.36ZM18.83 20.13l-4.19.93 1-4.15 9.55-9.57 3.23 3.23ZM29.5 9.43 26.27 6.2l1.85-1.85 3.23 3.23Z"></path><path fill="none" d="M0 0h36v36H0z"></path></svg><span>编辑</span></a><button id="darkMode" type="button"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="light" height="1em" width="1em">
  <path d="M6.995 12c0 2.761 2.246 5.007 5.007 5.007s5.007-2.246 5.007-5.007-2.246-5.007-5.007-5.007S6.995 9.239 6.995 12zM11 19h2v3h-2zm0-17h2v3h-2zm-9 9h3v2H2zm17 0h3v2h-3zM5.637 19.778l-1.414-1.414 2.121-2.121 1.414 1.414zM16.242 6.344l2.122-2.122 1.414 1.414-2.122 2.122zM6.344 7.759 4.223 5.637l1.415-1.414 2.12 2.122zm13.434 10.605-1.414 1.414-2.122-2.122 1.414-1.414z"></path>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" class="dark" height="1em" width="1em">
  <path d="M12 11.807A9.002 9.002 0 0 1 10.049 2a9.942 9.942 0 0 0-5.12 2.735c-3.905 3.905-3.905 10.237 0 14.142 3.906 3.906 10.237 3.905 14.143 0a9.946 9.946 0 0 0 2.735-5.119A9.003 9.003 0 0 1 12 11.807z"></path>
</svg>
</button><script src="../js/dark.js?v=1.4.1"></script><a href="https://github.com/jaywcjlove/reference" class="" target="__blank"><svg viewBox="0 0 16 16" fill="currentColor" height="1em" width="1em"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.012 8.012 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path></svg></a></div></div></nav><div class="wrap h1body-exist max-container"><header class="wrap-header h1wrap"><h1 id="vim-备忘清单"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" fill="currentColor" height="1em" width="1em">
  <path d="M32 15.979h-.036l-5.755-5.755 5.734-5.885V1.948l-.865-.865H20.146l-.88.807v1.396L16.021.036V0L16 .021 15.979 0v.036L14.26 1.755l-.719-.719H2.713l-.849.927v2.51l.818.823h.964v7.078L.037 15.983H.001l.021.016-.021.021h.036l3.609 3.604v8.625l1.208.698h3.094l2.479-2.542 5.552 5.557v.036l.021-.021.021.021v-.036l3.344-3.344h.646a.352.352 0 0 0 .333-.24l.198-.568a.356.356 0 0 0-.052-.323l1.948-1.948-.813 2.615a.352.352 0 0 0 .234.443.242.242 0 0 0 .104.021h2.432a.365.365 0 0 0 .323-.219l.219-.526a.333.333 0 0 0-.005-.271.313.313 0 0 0-.193-.188.45.45 0 0 0-.13-.031h-.099l1.12-3.521h1.641l-1.354 4.292a.359.359 0 0 0 .343.459h2.667a.362.362 0 0 0 .333-.224l.219-.573a.355.355 0 0 0-.334-.474h-.193l1.505-4.901a.347.347 0 0 0-.052-.318l-.5-.672v-.005a.355.355 0 0 0-.281-.141h-1.917a.348.348 0 0 0-.25.109l-.536.589h-.828l-.057-.063 5.927-5.927h.036l-.021-.016zM13.12 28.188l2.104-6.016h-.672l.401-.406h2.208l-2.083 6.078h.833l-.109.344zm4.922-10.027.203.203-.359 1.229-.302.302h-1.292l-.24-.24.417-1.161.38-.333zm-10.589 9.61H5.172l-.354-.198V4.12H3.172l-.135-.13V2.422l.193-.208h9.828l.286.286v1.479l-.193.229h-1.438v11.583L23.458 4.208h-2.781l-.234-.25V2.406l.161-.146h9.984l.177.177v1.427L17.307 17.666h-.557l-.026.005a.41.41 0 0 0-.156.078l-.458.396-.005.005a.407.407 0 0 0-.099.146l-.391 1.109zm19.693-5.266.63-.693h1.776l.417.552-1.688 5.474h.656l-.109.281h-2.375l1.5-4.755h-2.688l-1.438 4.521h.568l-.099.234h-2.141l1.479-4.729h-2.797l-1.417 4.453h.583l-.099.276H17.69l2.021-5.948h-.781l.12-.359h2.198l.693.714h1.208l.656-.734h1.411l.656.714z"></path>
</svg>
<a aria-hidden="true" tabindex="-1" href="#vim-备忘清单"><span class="icon icon-link"></span></a>Vim 备忘清单</h1><div class="wrap-body">
<p><a href="http://www.vim.org/">Vim</a> 8.2 快速参考备忘单的有用集合，可帮助您更快地学习 vim 编辑器。</p>
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
  <path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#入门">入门</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#运动图">运动图</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#左右动作">左右动作</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#上下动作">上下动作</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#动作">动作</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#字词">字(词)</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#行">行</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#字符串">字符串</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#文档">文档</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#窗口">窗口</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#插入模式">插入模式</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#保存和退出">保存和退出</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#正常模式">正常模式</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#剪切和粘贴">剪切和粘贴</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#在可视化模式下">在可视化模式下</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#重复">重复</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#可视化模式">可视化模式</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#宏">宏</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#vim-运算符">Vim 运算符</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#用法">用法</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#可用运算符">可用运算符</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#例子">例子</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#计数">计数</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#vim-文本对象">Vim 文本对象</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#用法-1">用法</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#文本对象">文本对象</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#删除">删除</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#选择">选择</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#杂项">杂项</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#vim-多个文件">Vim 多个文件</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#buffers-缓冲器">Buffers (缓冲器)</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#窗口-1">窗口</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#选项卡">选项卡</a><a aria-hidden="true" class="leve4 tocs-link" data-num="4" href="#正常模式-1">正常模式</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#vim-搜索和替换">Vim 搜索和替换</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#搜索">搜索</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#更换行">更换行</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#替换文件">替换文件</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#范围">范围</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#全局命令">全局命令</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#inverse逆-g">Inverse(逆) :g</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#flags标志">Flags(标志)</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#替换表达式魔术">替换表达式（魔术）</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#例子-1">例子</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#vimdiff">Vimdiff</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#用法-2">用法</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#编辑">编辑</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#折叠">折叠</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#跳跃">跳跃</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#各种各样的">各种各样的</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#case">Case</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#跳跃-1">跳跃</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#其他命令行">其他命令行</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#导航">导航</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#计数器">计数器</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#选项卡-1">选项卡</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#格式化">格式化</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#标记">标记</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#计算器">计算器</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#shell">Shell</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#命令行">命令行</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#技巧">技巧</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#理解-vim">理解 Vim</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#动词理解">动词理解</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#名词理解">名词理解</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#介词理解">介词理解</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#数词理解">数词理解</a><a aria-hidden="true" class="leve3 tocs-link" data-num="3" href="#组词为句理解">组词为句理解</a><a aria-hidden="true" class="leve2 tocs-link" data-num="2" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="入门"><a aria-hidden="true" tabindex="-1" href="#入门"><span class="icon icon-link"></span></a>入门</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="运动图"><a aria-hidden="true" tabindex="-1" href="#运动图"><span class="icon icon-link"></span></a>运动图</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">▼/▶ 光标   ▽/▷ 目标
</span></code></pre>
<h4 id="左右动作"><a aria-hidden="true" tabindex="-1" href="#左右动作"><span class="icon icon-link"></span></a>左右动作</h4>
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">╭┈┈┈┈┈┈┈┈┈┈┈┈┈ <span class="token operator">|</span>      
</span><span class="code-line">├┈┈┈┈┈┈┈┈┈┈┈┈┈ <span class="token number">0</span>      $ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮
</span><span class="code-line">┆  ╭┈┈┈┈┈┈┈┈┈┈ ^      fe ┈┈┈┈┈┈┈┈╮       ┆
</span><span class="code-line">┆  ┆  ╭┈┈┈┈┈┈┈ Fo     te ┈┈┈┈┈┈┈╮┆       ┆
</span><span class="code-line">┆  ┆  ┆╭┈┈┈┈┈┈ To     <span class="token number">30</span><span class="token operator">|</span> ┈┈┈╮  ┆┆       ┆
</span><span class="code-line">┆  ┆  ┆┆ ╭┈┈┈┈ ge     w ┈┈┈╮ ┆  ┆┆       ┆
</span><span class="code-line">┆  ┆  ┆┆ ┆ ╭┈┈ b      e ┈╮ ┆ ┆  ┆┆       ┆
</span><span class="code-line">┆  ┆  ┆┆ ┆ ┆  ╭h      l╮ ┆ ┆ ┆  ┆┆       ┆
</span><span class="code-line">▽  ▽  ▽▽ ▽ ▽  ▽▼      ▼▽ ▽ ▽ ▽  ▽▽       ▽
</span><span class="code-line">   <span class="token builtin class-name">echo</span> <span class="token string">"A cheatsheet from quickReference"</span>
</span></code></pre>
<h4 id="上下动作"><a aria-hidden="true" tabindex="-1" href="#上下动作"><span class="icon icon-link"></span></a>上下动作</h4>
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">                  - SCREEN <span class="token number">1</span> START
</span><span class="code-line">   ╭┈┬┈┈┈┈┈┈┈┈┈▷  <span class="token comment">#!/usr/bin/python</span>
</span><span class="code-line">   ┆ ┆     ╭┈┈┈▷      
</span><span class="code-line">   ┆ ┆     ┆      print<span class="token punctuation">(</span><span class="token string">"Hello"</span><span class="token punctuation">)</span>
</span><span class="code-line">   ┆ ┆     <span class="token punctuation">{</span> <span class="token punctuation">}</span> ▶  print<span class="token punctuation">(</span><span class="token string">"Vim"</span><span class="token punctuation">)</span>
</span><span class="code-line">   ┆ ┆       ┆    print<span class="token punctuation">(</span><span class="token string">"!"</span><span class="token punctuation">)</span>
</span><span class="code-line">   ┆ ┆       └┈▷     
</span><span class="code-line">   ┆ ┆ ╭┈┈┈┬┈┈┈▷  print<span class="token punctuation">(</span><span class="token string">"Welcome"</span><span class="token punctuation">)</span>
</span><span class="code-line">G gg H M L k j ▶  print<span class="token punctuation">(</span><span class="token string">"to"</span><span class="token punctuation">)</span>
</span><span class="code-line">┆        ┆   └┈▷  print<span class="token punctuation">(</span><span class="token string">"Quick Reference"</span><span class="token punctuation">)</span>
</span><span class="code-line">┆        ┆        print<span class="token punctuation">(</span><span class="token string">"/vim"</span><span class="token punctuation">)</span>
</span><span class="code-line">┆        ┆     
</span><span class="code-line">┆        ╰┈┈┈┈┈▷ 
</span><span class="code-line">┆                 - SCREEN <span class="token number">1</span> END
</span><span class="code-line">╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈▷  print<span class="token punctuation">(</span><span class="token string">"SCREEN 2"</span><span class="token punctuation">)</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="动作"><a aria-hidden="true" tabindex="-1" href="#动作"><span class="icon icon-link"></span></a>动作</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->





















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>h</code> | <code>j</code> | <code>k</code> | <code>l</code></td><td>方向键</td></tr><tr><td align="left"><code>&#x3C;C-u></code> <em>/</em> <code>&#x3C;C-d></code></td><td>上/下半页</td></tr><tr><td align="left"><code>&#x3C;C-b></code> <em>/</em> <code>&#x3C;C-f></code></td><td>向上/向下翻页</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<h4 id="字词"><a aria-hidden="true" tabindex="-1" href="#字词"><span class="icon icon-link"></span></a>字(词)</h4>

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>b</code> <em>/</em> <code>w</code></td><td>上一个/下一个单词</td></tr><tr><td align="left"><code>ge</code> <em>/</em> <code>e</code></td><td>上一个/下一个词尾</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<h4 id="行"><a aria-hidden="true" tabindex="-1" href="#行"><span class="icon icon-link"></span></a>行</h4>

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>0</code> <em>(zero)</em> <em>/</em> <code>$</code></td><td>行的开始/结束</td></tr><tr><td align="left"><code>^</code></td><td>行开头 <em>(非空白)</em></td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<h4 id="字符串"><a aria-hidden="true" tabindex="-1" href="#字符串"><span class="icon icon-link"></span></a>字符串</h4>





















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>Fe</code> <em>/</em> <code>fe</code></td><td>移动到上一个/下一个<code>e</code></td></tr><tr><td align="left"><code>To</code> <em>/</em> <code>to</code></td><td>在上一个/下一个<code>o</code>之前/之后移动</td></tr><tr><td align="left"><code>|</code> <em>/</em> <code>n|</code></td><td>转到第一个/<code>n</code>列</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<h4 id="文档"><a aria-hidden="true" tabindex="-1" href="#文档"><span class="icon icon-link"></span></a>文档</h4>





















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>gg</code> <em>/</em> <code>G</code></td><td>第一行/最后一行</td></tr><tr><td align="left"><code>:n</code> | <code>nG</code></td><td>转到第 <code>n</code> 行</td></tr><tr><td align="left"><code>}</code> <em>/</em> <code>{</code></td><td>下一个/上一个空行</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<h4 id="窗口"><a aria-hidden="true" tabindex="-1" href="#窗口"><span class="icon icon-link"></span></a>窗口</h4>

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>H</code> <em>/</em> <code>M</code> <em>/</em> <code>L</code></td><td>上/中/下屏幕</td></tr><tr><td align="left"><code>zt</code> <em>/</em> <code>zz</code> <em>/</em>  <code>zb</code></td><td>上/中/下这条线</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="插入模式"><a aria-hidden="true" tabindex="-1" href="#插入模式"><span class="icon icon-link"></span></a>插入模式</h3><div class="wrap-body">





































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>i</code> <em>/</em> <code>a</code></td><td>在光标之前/之后插入</td></tr><tr><td align="left"><code>I</code> <em>/</em> <code>A</code></td><td>插入行的开始/结束</td></tr><tr><td align="left"><code>o</code> <em>/</em> <code>O</code> <em>(letter)</em></td><td>在下方/上方插入新行</td></tr><tr><td align="left"><code>s</code> <em>/</em> <code>S</code></td><td>删除字符/行并插入</td></tr><tr><td align="left"><code>C</code> <em>/</em> <code>cc</code></td><td>更改到/当前行的结尾</td></tr><tr><td align="left"><code>gi</code></td><td>在最后一个插入点插入</td></tr><tr><td align="left"><code>Esc</code> | <code>&#x3C;C-[></code></td><td>退出插入模式</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="保存和退出"><a aria-hidden="true" tabindex="-1" href="#保存和退出"><span class="icon icon-link"></span></a>保存和退出</h3><div class="wrap-body">

















































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>:w</code></td><td>保存</td></tr><tr><td align="left"><code>:q</code></td><td>关闭文件</td></tr><tr><td align="left"><code>:wq</code> | <code>:x</code> | <code>ZZ</code></td><td>保存并退出</td></tr><tr><td align="left"><code>:wqa</code></td><td>保存并退出所有文件</td></tr><tr><td align="left"><code>:q!</code> | <code>ZQ</code></td><td>强制退出</td></tr><tr><td align="left"><code>:qa</code></td><td>关闭所有文件</td></tr><tr><td align="left"><code>:qa!</code></td><td>强制退出所有文件</td></tr><tr><td align="left"><code>:w</code> new.txt</td><td>写入<code>new.txt</code></td></tr><tr><td align="left"><code>:sav</code> new.txt</td><td>保存并编辑<code>new.txt</code></td></tr><tr><td align="left"><code>:w</code> !sudo tee %</td><td>写入只读文件</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="正常模式"><a aria-hidden="true" tabindex="-1" href="#正常模式"><span class="icon icon-link"></span></a>正常模式</h3><div class="wrap-body">

































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>r</code></td><td>替换一个字符</td></tr><tr><td align="left"><code>R</code></td><td>进入替换模式</td></tr><tr><td align="left"><code>u</code> <em>/</em> <code>3u</code></td><td>撤消更改<code>1</code>/<code>3</code>次</td></tr><tr><td align="left"><code>U</code></td><td>在一行上撤消更改</td></tr><tr><td align="left"><code>J</code></td><td>加入下一行</td></tr><tr><td align="left"><code>&#x3C;C-r></code> <em>/</em> 5 <code>&#x3C;C-r></code></td><td>重做更改<code>1</code>/<code>5</code>次</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="剪切和粘贴"><a aria-hidden="true" tabindex="-1" href="#剪切和粘贴"><span class="icon icon-link"></span></a>剪切和粘贴</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->

















































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>x</code></td><td>删除字符 <em>(剪切)</em></td></tr><tr><td align="left"><code>p</code> <em>/</em> <code>P</code></td><td>在之后/之前粘贴</td></tr><tr><td align="left"><code>xp</code></td><td>交换两个字符</td></tr><tr><td align="left"><code>D</code></td><td>删除到行尾 <em>(剪切)</em></td></tr><tr><td align="left"><code>dw</code></td><td>删除单词 <em>(剪切)</em></td></tr><tr><td align="left"><code>dd</code></td><td>删除线 <em>(剪切)</em></td></tr><tr><td align="left"><code>ddp</code></td><td>交换两条线</td></tr><tr><td align="left"><code>yy</code></td><td>拉线 <em>(复制)</em></td></tr><tr><td align="left"><code>"*p</code> | <code>"+p</code></td><td>从系统剪贴板粘贴</td></tr><tr><td align="left"><code>"*y</code> | <code>"+y</code></td><td>粘贴到系统剪贴板</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<h4 id="在可视化模式下"><a aria-hidden="true" tabindex="-1" href="#在可视化模式下"><span class="icon icon-link"></span></a>在可视化模式下</h4>





















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>d</code> <em>|</em> <code>x</code></td><td>删除选择 <em>(剪切)</em></td></tr><tr><td align="left"><code>s</code></td><td>替换选择</td></tr><tr><td align="left"><code>y</code></td><td>Yank 选择 <em>(复制)</em></td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="重复"><a aria-hidden="true" tabindex="-1" href="#重复"><span class="icon icon-link"></span></a>重复</h3><div class="wrap-body">





























<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>.</code></td><td>重复上一个命令</td></tr><tr><td align="left"><code>;</code></td><td>重复最新的 <code>f</code>、<code>t</code>、<code>F</code> 或 <code>T</code></td></tr><tr><td align="left"><code>,</code></td><td>重复最新的<code>f</code>、<code>t</code>、<code>F</code>或<code>T</code>颠倒</td></tr><tr><td align="left"><code>&#x26;</code></td><td>重复最后一个<code>:s</code></td></tr><tr><td align="left"><code>@:</code></td><td>重复命令行命令</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="可视化模式"><a aria-hidden="true" tabindex="-1" href="#可视化模式"><span class="icon icon-link"></span></a>可视化模式</h3><div class="wrap-body">





























<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>v</code></td><td>进入可视化模式</td></tr><tr><td align="left"><code>V</code></td><td>进入视线模式</td></tr><tr><td align="left"><code>&#x3C;C-v></code></td><td>进入可视块模式</td></tr><tr><td align="left"><code>ggVG</code></td><td>选择所有文本</td></tr><tr><td align="left"><code>></code> <em>/</em> <code>&#x3C;</code></td><td>向右/向左移动文本</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="宏"><a aria-hidden="true" tabindex="-1" href="#宏"><span class="icon icon-link"></span></a>宏</h3><div class="wrap-body">





























<table class="shortcuts"><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>qi</code></td><td>录制宏 <code>i</code></td></tr><tr><td align="left"><code>q</code></td><td>停止录制宏</td></tr><tr><td align="left"><code>@i</code></td><td>运行宏<code>i</code></td></tr><tr><td align="left"><code>7@i</code></td><td>运行宏 <code>i</code> 7 次</td></tr><tr><td align="left"><code>@@</code></td><td>重复上一个宏</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<p>您可以为任何字母保存宏，而不仅仅是 <code>i</code></p>
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="vim-运算符"><a aria-hidden="true" tabindex="-1" href="#vim-运算符"><span class="icon icon-link"></span></a>Vim 运算符</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 style="background:#d7a100;" id="用法"><a aria-hidden="true" tabindex="-1" href="#用法"><span class="icon icon-link"></span></a>用法</h3><div class="wrap-body">
<!--rehype:style=background:#d7a100;-->

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>d</code></td><td><yel>w</yel></td></tr><tr><td align="left">运算符</td><td>动作</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<p>将 <a href="#%E5%8F%AF%E7%94%A8%E8%BF%90%E7%AE%97%E7%AC%A6">可用运算符</a> 与 <a href="#%E5%8A%A8%E4%BD%9C">动作</a> 结合使用以使用它们</p>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="可用运算符"><a aria-hidden="true" tabindex="-1" href="#可用运算符"><span class="icon icon-link"></span></a>可用运算符</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->





















































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>d</code></td><td>删除</td></tr><tr><td align="left"><code>y</code></td><td>Yank <em>(复制)</em></td></tr><tr><td align="left"><code>c</code></td><td>更改 <em>(删除然后插入)</em></td></tr><tr><td align="left"><code>p</code></td><td>粘贴</td></tr><tr><td align="left"><code>=</code></td><td>格式代码</td></tr><tr><td align="left"><code>g~</code></td><td>切换案例</td></tr><tr><td align="left"><code>gU</code></td><td>大写</td></tr><tr><td align="left"><code>gu</code></td><td>小写</td></tr><tr><td align="left"><code>></code></td><td>右缩进</td></tr><tr><td align="left"><code>&#x3C;</code></td><td>左缩进</td></tr><tr><td align="left"><code>!</code></td><td>通过外部程序过滤</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="例子"><a aria-hidden="true" tabindex="-1" href="#例子"><span class="icon icon-link"></span></a>例子</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->

























































<table class="show-header"><thead><tr><th align="left">组合</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>d</code><yel>d</yel></td><td>删除当前行</td></tr><tr><td align="left"><code>d</code><yel>j</yel></td><td>删除两行</td></tr><tr><td align="left"><code>d</code><yel>w</yel></td><td>删除到下一个单词</td></tr><tr><td align="left"><code>d</code><yel>b</yel></td><td>删除到单词的开头</td></tr><tr><td align="left"><code>d</code><yel>fa</yel></td><td>删除直到 <code>a</code> 字符</td></tr><tr><td align="left"><code>d</code><yel>/hello</yel></td><td>删除直到 <code>hello</code></td></tr><tr><td align="left"><code>c</code><yel>c</yel></td><td>更改当前行，与 <code>S</code> 同义</td></tr><tr><td align="left"><code>y</code><yel>y</yel></td><td>复制当前行</td></tr><tr><td align="left"><code>></code><yel>j</yel></td><td>缩进 2 行</td></tr><tr><td align="left">gg<code>d</code><yel>G</yel></td><td>删除完整的文档</td></tr><tr><td align="left">gg<code>=</code><yel>G</yel></td><td>缩进一个完整的文档</td></tr><tr><td align="left">gg<code>y</code><yel>G</yel></td><td>复制整个文档</td></tr></tbody></table>
<!--rehype:className=show-header-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="计数"><a aria-hidden="true" tabindex="-1" href="#计数"><span class="icon icon-link"></span></a>计数</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line"><span class="token punctuation">[</span>数字<span class="token punctuation">]</span> <span class="token operator">&#x3C;</span>运算符<span class="token operator">></span> <span class="token operator">&#x3C;</span>动作<span class="token operator">></span>
</span><span class="code-line"><span class="token operator">&#x3C;</span>运算符<span class="token operator">></span> <span class="token punctuation">[</span>数字<span class="token punctuation">]</span> <span class="token operator">&#x3C;</span>动作<span class="token operator">></span>
</span></code></pre>
<hr>





























<table><thead><tr><th align="left">组合</th><th>说明</th></tr></thead><tbody><tr><td align="left">2<code>d</code><yel>d</yel></td><td>删除 <code>2</code> 行</td></tr><tr><td align="left">6<code>y</code><yel>y</yel></td><td>复制 <code>6</code> 行</td></tr><tr><td align="left"><code>d</code>3<yel>w</yel></td><td>删除 <code>3</code> 字</td></tr><tr><td align="left"><code>d</code>5<yel>j</yel></td><td>向下删除 <code>5</code> 行</td></tr><tr><td align="left"><code>></code>4<yel>k</yel></td><td>向上缩进 <code>4</code> 行</td></tr></tbody></table>
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="vim-文本对象"><a aria-hidden="true" tabindex="-1" href="#vim-文本对象"><span class="icon icon-link"></span></a>Vim 文本对象</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 style="background:#d7a100;" id="用法-1"><a aria-hidden="true" tabindex="-1" href="#用法-1"><span class="icon icon-link"></span></a>用法</h3><div class="wrap-body">
<!--rehype:style=background:#d7a100;-->

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>v</code></td><td>        <pur>i</pur> <em>/</em> <pur>a</pur></td></tr><tr><td align="left">Operator</td><td><pur>i</pur>nner(内部) <em>/</em> <pur>a</pur>round(周围)</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<p>文本块内部或周围使用 <a href="#%E5%8F%AF%E7%94%A8%E8%BF%90%E7%AE%97%E7%AC%A6">operator</a> 进行操作</p>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="文本对象"><a aria-hidden="true" tabindex="-1" href="#文本对象"><span class="icon icon-link"></span></a>文本对象</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->

















































<table><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><yel>p</yel></td><td>段落</td></tr><tr><td align="left"><yel>w</yel></td><td>单词</td></tr><tr><td align="left"><yel>W</yel></td><td>WORD <br> <em>(被空格包围)</em></td></tr><tr><td align="left"><yel>s</yel></td><td>句子</td></tr><tr><td align="left"><yel>[</yel> <yel>(</yel> <yel>{</yel> <yel>&#x3C;</yel></td><td>[]、() 或 {} 块</td></tr><tr><td align="left"><yel>]</yel> <yel>)</yel> <yel>}</yel> <yel>></yel></td><td>[]、() 或 {} 块</td></tr><tr><td align="left"><yel>'</yel> <yel>"</yel> <yel>`</yel></td><td>带引号的字符串</td></tr><tr><td align="left"><yel>b</yel></td><td>一个块 [(</td></tr><tr><td align="left"><yel>B</yel></td><td>[{中的一个块</td></tr><tr><td align="left"><yel>t</yel></td><td>一个 HTML 标签块</td></tr></tbody></table>
<p>查看 <code>:help text-objects</code></p>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="删除"><a aria-hidden="true" tabindex="-1" href="#删除"><span class="icon icon-link"></span></a>删除</h3><div class="wrap-body">





























<table><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>d</code><pur>i</pur><yel>w</yel></td><td>删除内词</td></tr><tr><td align="left"><code>d</code><pur>i</pur><yel>s</yel></td><td>删除内句</td></tr><tr><td align="left"><code>d</code><pur>i</pur><yel>"</yel></td><td>引号中删除</td></tr><tr><td align="left"><code>d</code><pur>a</pur><yel>"</yel></td><td>删除引号 <em>(包括引号)</em></td></tr><tr><td align="left"><code>d</code><pur>i</pur><yel>p</yel></td><td>删除段落</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="选择"><a aria-hidden="true" tabindex="-1" href="#选择"><span class="icon icon-link"></span></a>选择</h3><div class="wrap-body">





































<table><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>v</code><pur>i</pur><yel>"</yel></td><td>选择内引号“<code>...</code>{.underline}”</td></tr><tr><td align="left"><code>v</code><pur>a</pur><yel>"</yel></td><td>选择引号<code>"..."</code>{.underline}</td></tr><tr><td align="left"><code>v</code><pur>i</pur><yel>[</yel></td><td>选择内括号 [<code>...</code>{.underline}]</td></tr><tr><td align="left"><code>v</code><pur>a</pur><yel>[</yel></td><td>选择括号<code>[...]</code>{.underline}</td></tr><tr><td align="left"><code>v</code><pur>i</pur><yel>w</yel></td><td>选择内词</td></tr><tr><td align="left"><code>v</code><pur>i</pur><yel>p</yel></td><td>选择内部段落</td></tr><tr><td align="left"><code>v</code><pur>i</pur><yel>p</yel><pur>i</pur><yel>p</yel></td><td>选择更多段落</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="杂项"><a aria-hidden="true" tabindex="-1" href="#杂项"><span class="icon icon-link"></span></a>杂项</h3><div class="wrap-body">

































<table><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>c</code><pur>i</pur><yel>w</yel></td><td>换内字</td></tr><tr><td align="left"><code>c</code><pur>i</pur><yel>"</yel></td><td>更改内部引号</td></tr><tr><td align="left"><code>c</code><pur>i</pur><yel>t</yel></td><td>更改内部标签 (HTML)</td></tr><tr><td align="left"><code>c</code><pur>i</pur><yel>p</yel></td><td>更改内部段落</td></tr><tr><td align="left"><code>y</code><pur>i</pur><yel>p</yel></td><td>Yank 段落</td></tr><tr><td align="left"><code>y</code><pur>a</pur><yel>p</yel></td><td>Yank 段落 <em>(包括换行符)</em></td></tr></tbody></table>
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="vim-多个文件"><a aria-hidden="true" tabindex="-1" href="#vim-多个文件"><span class="icon icon-link"></span></a>Vim 多个文件</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="buffers-缓冲器"><a aria-hidden="true" tabindex="-1" href="#buffers-缓冲器"><span class="icon icon-link"></span></a>Buffers (缓冲器)</h3><div class="wrap-body">

























































<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:e file</code></td><td>在新缓冲区中编辑文件</td></tr><tr><td align="left"><code>:bn</code></td><td>转到下一个缓冲区</td></tr><tr><td align="left"><code>:bp</code></td><td>转到上一个缓冲区</td></tr><tr><td align="left"><code>:bd</code></td><td>从缓冲区列表中删除文件</td></tr><tr><td align="left"><code>:b 5</code></td><td>打开缓冲区 #5</td></tr><tr><td align="left"><code>:b file</code></td><td>按文件转到缓冲区</td></tr><tr><td align="left"><code>:ls</code></td><td>列出所有打开的缓冲区</td></tr><tr><td align="left"><code>:sp file</code></td><td>打开和拆分窗口</td></tr><tr><td align="left"><code>:vs file</code></td><td>打开和垂直拆分窗口</td></tr><tr><td align="left"><code>:hid</code></td><td>隐藏此缓冲区</td></tr><tr><td align="left"><code>:wn</code></td><td>写入文件并移至下一个</td></tr><tr><td align="left"><code>:tab ba</code></td><td>将所有缓冲区编辑为选项卡</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="窗口-1"><a aria-hidden="true" tabindex="-1" href="#窗口-1"><span class="icon icon-link"></span></a>窗口</h3><div class="wrap-body">

























































<table class="shortcuts"><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>&#x3C;C-w></code> <code>s</code></td><td>拆分窗口</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>v</code></td><td>垂直拆分窗口</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>w</code></td><td>切换窗口</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>q</code></td><td>退出一个窗口</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>T</code></td><td>拆分成一个新标签</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>x</code></td><td>用下一个交换当前</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>-</code>  <em>/</em> <code>+</code></td><td>减少/增加高度</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>&#x3C;</code>  <em>/</em> <code>></code></td><td>减少/增加宽度</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>|</code></td><td>最大宽度</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>=</code></td><td>同样高和宽</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>h</code> <em>/</em> <code>l</code></td><td>转到左/右窗口</td></tr><tr><td align="left"><code>&#x3C;C-w></code> <code>j</code> <em>/</em> <code>k</code></td><td>转到上/下窗口</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-exist"><div class="wrap-header h3wrap"><h3 id="选项卡"><a aria-hidden="true" tabindex="-1" href="#选项卡"><span class="icon icon-link"></span></a>选项卡</h3><div class="wrap-body">

















































<table><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>:tabe [file]</code></td><td><yel>E</yel>在新选项卡中编辑文件</td></tr><tr><td align="left"><code>:tabf [file]</code></td><td>如果在新选项卡中存在则打开</td></tr><tr><td align="left"><code>:tabc</code></td><td><yel>C</yel>失去当前选项卡</td></tr><tr><td align="left"><code>:tabo</code></td><td>关闭<yel>o</yel>其他选项卡</td></tr><tr><td align="left"><code>:tabs</code></td><td>列出所有<yel>标签</yel></td></tr><tr><td align="left"><code>:tabr</code></td><td>转到第一个<yel>r</yel>标签</td></tr><tr><td align="left"><code>:tabl</code></td><td>转到 <yel>l</yel>ast 选项卡</td></tr><tr><td align="left"><code>:tabm 0</code></td><td><yel>我</yel>转到位置 <code>0</code></td></tr><tr><td align="left"><code>:tabn</code></td><td>转到 <yel>n</yel>ext 选项卡</td></tr><tr><td align="left"><code>:tabp</code></td><td>转到<yel>p</yel>上一个标签</td></tr></tbody></table>
<h4 id="正常模式-1"><a aria-hidden="true" tabindex="-1" href="#正常模式-1"><span class="icon icon-link"></span></a>正常模式</h4>





















<table><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>gt</code></td><td>转到 <yel>n</yel>ext 选项卡</td></tr><tr><td align="left"><code>gT</code></td><td>转到<yel>p</yel>上一个标签</td></tr><tr><td align="left"><code>2gt</code></td><td>转到标签编号 <code>2</code></td></tr></tbody></table>
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="vim-搜索和替换"><a aria-hidden="true" tabindex="-1" href="#vim-搜索和替换"><span class="icon icon-link"></span></a>Vim 搜索和替换</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="搜索"><a aria-hidden="true" tabindex="-1" href="#搜索"><span class="icon icon-link"></span></a>搜索</h3><div class="wrap-body">









































<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>/foo</code></td><td>向前搜索</td></tr><tr><td align="left"><code>/foo\c</code></td><td>向前搜索 <em>(不区分大小写)</em></td></tr><tr><td align="left"><code>?foo</code></td><td>向后搜索</td></tr><tr><td align="left"><code>/\v\d+</code></td><td>使用 <a href="./regex.html">regex</a> 搜索</td></tr><tr><td align="left"><code>n</code></td><td>下一个匹配的搜索模式</td></tr><tr><td align="left"><code>N</code></td><td>上一个匹配的搜索</td></tr><tr><td align="left"><code>*</code></td><td>向前搜索当前单词</td></tr><tr><td align="left"><code>#</code></td><td>向后搜索当前单词</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="更换行"><a aria-hidden="true" tabindex="-1" href="#更换行"><span class="icon icon-link"></span></a>更换行</h3><div class="wrap-body">
<pre class="language-vim"><code class="language-vim code-highlight"><span class="code-line"><span class="token punctuation">:</span><span class="token punctuation">[</span>range<span class="token punctuation">]</span>s<span class="token operator">/</span><span class="token punctuation">{</span>pattern<span class="token punctuation">}</span><span class="token operator">/</span><span class="token punctuation">{</span>str<span class="token punctuation">}</span><span class="token operator">/</span><span class="token punctuation">[</span>flags<span class="token punctuation">]</span>
</span></code></pre>
<hr>

































<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:s/old/new</code></td><td>先更换</td></tr><tr><td align="left"><code>:s/old/new/g</code></td><td>全部替换</td></tr><tr><td align="left"><code>:s/\vold/new/g</code></td><td>全部替换为 <a href="./regex.html">regex</a></td></tr><tr><td align="left"><code>:s/old/new/gc</code></td><td>全部替换_(确认)_</td></tr><tr><td align="left"><code>:s/old/new/i</code></td><td>先忽略大小写替换</td></tr><tr><td align="left"><code>:2,6s/old/new/g</code></td><td>在 <code>2</code>-<code>6</code> 行之间替换</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="替换文件"><a aria-hidden="true" tabindex="-1" href="#替换文件"><span class="icon icon-link"></span></a>替换文件</h3><div class="wrap-body">
<pre class="language-vim"><code class="language-vim code-highlight"><span class="code-line"><span class="token punctuation">:</span><span class="token operator">%</span>s<span class="token operator">/</span><span class="token punctuation">{</span>pattern<span class="token punctuation">}</span><span class="token operator">/</span><span class="token punctuation">{</span>str<span class="token punctuation">}</span><span class="token operator">/</span><span class="token punctuation">[</span>flags<span class="token punctuation">]</span>
</span></code></pre>
<hr>





























<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:%s/old/new</code></td><td>先更换</td></tr><tr><td align="left"><code>:%s/old/new/g</code></td><td>全部替换</td></tr><tr><td align="left"><code>:%s/old/new/gc</code></td><td>全部替换 <em>(确认)</em></td></tr><tr><td align="left"><code>:%s/old/new/gi</code></td><td>全部替换 <em>(忽略大小写)</em></td></tr><tr><td align="left"><code>:%s/\vold/new/g</code></td><td>全部替换为 <a href="./regex.html">regex</a></td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="范围"><a aria-hidden="true" tabindex="-1" href="#范围"><span class="icon icon-link"></span></a>范围</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->













































<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>%</code></td><td>整个文件</td></tr><tr><td align="left"><code>’&#x3C;,’></code></td><td>当前选择</td></tr><tr><td align="left"><code>5</code></td><td>第 <code>5</code> 行</td></tr><tr><td align="left"><code>5,10</code></td><td>第 <code>5</code> 行到第 <code>10</code> 行</td></tr><tr><td align="left"><code>$</code></td><td>最后一行</td></tr><tr><td align="left"><code>2,$</code></td><td>第 <code>2</code> 行到最后</td></tr><tr><td align="left"><code>.</code></td><td>当前行</td></tr><tr><td align="left"><code>,3</code></td><td>接下来的 <code>3</code> 行</td></tr><tr><td align="left"><code>-3,</code></td><td>转发 <code>3</code> 行</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="全局命令"><a aria-hidden="true" tabindex="-1" href="#全局命令"><span class="icon icon-link"></span></a>全局命令</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<pre class="language-vim"><code class="language-vim code-highlight"><span class="code-line"><span class="token punctuation">:</span><span class="token punctuation">[</span>range<span class="token punctuation">]</span>g<span class="token operator">/</span><span class="token punctuation">{</span>pattern<span class="token punctuation">}</span><span class="token operator">/</span><span class="token punctuation">[</span>command<span class="token punctuation">]</span>
</span></code></pre>
<hr>





































<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:g/foo/d</code></td><td>删除包含 <code>foo</code> 的行</td></tr><tr><td align="left"><code>:g!/foo/d</code></td><td>删除不包含 <code>foo</code> 的行</td></tr><tr><td align="left"><code>:g/^\s*$/d</code></td><td>删除所有空行</td></tr><tr><td align="left"><code>:g/foo/t$</code></td><td>将包含 <code>foo</code> 的行复制到 EOF</td></tr><tr><td align="left"><code>:g/foo/m$</code></td><td>将包含 <code>foo</code> 的行移动到 EOF</td></tr><tr><td align="left"><code>:g/^/m0</code></td><td>反转文件</td></tr><tr><td align="left"><code>:g/^/t.</code></td><td>复制每一行</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="inverse逆-g"><a aria-hidden="true" tabindex="-1" href="#inverse逆-g"><span class="icon icon-link"></span></a>Inverse(逆) :g</h3><div class="wrap-body">
<pre class="language-vim"><code class="language-vim code-highlight"><span class="code-line"><span class="token punctuation">:</span><span class="token punctuation">[</span>range<span class="token punctuation">]</span>v<span class="token operator">/</span><span class="token punctuation">{</span>pattern<span class="token punctuation">}</span><span class="token operator">/</span><span class="token punctuation">[</span>command<span class="token punctuation">]</span>
</span></code></pre>
<hr>













<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:v/foo/d</code></td><td>删除不包含<code>foo</code>的行 <br> <em>(还有<code>:g!/foo/d</code>)</em></td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="flags标志"><a aria-hidden="true" tabindex="-1" href="#flags标志"><span class="icon icon-link"></span></a>Flags(标志)</h3><div class="wrap-body">

























<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>g</code></td><td>替换所有出现</td></tr><tr><td align="left"><code>i</code></td><td>忽略大小写</td></tr><tr><td align="left"><code>I</code></td><td>不要忽略大小写</td></tr><tr><td align="left"><code>c</code></td><td>确认每个替换</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="替换表达式魔术"><a aria-hidden="true" tabindex="-1" href="#替换表达式魔术"><span class="icon icon-link"></span></a>替换表达式（魔术）</h3><div class="wrap-body">









































<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>&#x26;</code> <em>|</em> <code>\0</code></td><td>替换为整个匹配的</td></tr><tr><td align="left"><code>\1</code>...<code>\9</code></td><td>替换为 0-9 组</td></tr><tr><td align="left"><code>\u</code></td><td>大写下一个字母</td></tr><tr><td align="left"><code>\U</code></td><td>后面的大写字符</td></tr><tr><td align="left"><code>\l</code></td><td>小写下一个字母</td></tr><tr><td align="left"><code>\L</code></td><td>后面的字符小写</td></tr><tr><td align="left"><code>\e</code></td><td><code>\u</code>、<code>\U</code>、<code>\l</code> 和 <code>\L</code> 的结尾</td></tr><tr><td align="left"><code>\E</code></td><td><code>\u</code>、<code>\U</code>、<code>\l</code> 和 <code>\L</code> 的结尾</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="例子-1"><a aria-hidden="true" tabindex="-1" href="#例子-1"><span class="icon icon-link"></span></a>例子</h3><div class="wrap-body">
<!--rehype:wrap-class=col-span-2-->
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">:s/a<span class="token punctuation">\</span><span class="token operator">|</span>b/xxx<span class="token punctuation">\</span>0xxx/g               <span class="token comment"># 将 "a b"      修改为 "xxxaxxx xxxbxxx"</span>
</span><span class="code-line">:s/test/<span class="token punctuation">\</span>U<span class="token operator">&#x26;</span> file/                <span class="token comment"># 将 "test"     修改为 "TEST FILE"</span>
</span><span class="code-line">:s/<span class="token punctuation">\</span><span class="token punctuation">(</span>test<span class="token punctuation">\</span><span class="token punctuation">)</span>/<span class="token punctuation">\</span>U<span class="token punctuation">\</span><span class="token number">1</span><span class="token punctuation">\</span>e file/         <span class="token comment"># 将 "test"     修改为 "TEST file"</span>
</span><span class="code-line">:s/<span class="token punctuation">\</span>v<span class="token punctuation">(</span><span class="token punctuation">[</span>abc<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">[</span>efg<span class="token punctuation">]</span><span class="token punctuation">)</span>/<span class="token punctuation">\</span><span class="token number">2</span><span class="token punctuation">\</span><span class="token number">1</span>/g       <span class="token comment"># 将 "af fa bg" 修改为 "fa fa gb"</span>
</span><span class="code-line">:s/<span class="token punctuation">\</span>v<span class="token punctuation">\</span>w+/<span class="token punctuation">\</span>u<span class="token punctuation">\</span><span class="token number">0</span>/g                  <span class="token comment"># 将 "bla bla"  修改为 "Bla Bla"</span>
</span><span class="code-line">:s/<span class="token punctuation">\</span>v<span class="token punctuation">(</span><span class="token punctuation">[</span>ab<span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token operator">|</span><span class="token punctuation">(</span><span class="token punctuation">[</span>cd<span class="token punctuation">]</span><span class="token punctuation">)</span>/<span class="token punctuation">\</span>1x/g         <span class="token comment"># 将 "a b c d"  修改为 "ax bx x x"</span>
</span><span class="code-line">:%s/.*/<span class="token punctuation">\</span>L<span class="token operator">&#x26;</span>/                      <span class="token comment"># 将 "HTML"     修改为 "html"</span>
</span><span class="code-line">:s/<span class="token punctuation">\</span>v<span class="token operator">&#x3C;</span><span class="token punctuation">(</span><span class="token builtin class-name">.</span><span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">\</span>w*<span class="token punctuation">)</span>/<span class="token punctuation">\</span>u<span class="token punctuation">\</span><span class="token number">1</span><span class="token punctuation">\</span>L<span class="token punctuation">\</span><span class="token number">2</span>/g        <span class="token comment"># 将单词的每个首字母大写</span>
</span><span class="code-line">:%s/^<span class="token punctuation">\</span><span class="token punctuation">(</span>.*<span class="token punctuation">\</span><span class="token punctuation">)</span><span class="token punctuation">\</span>n<span class="token punctuation">\</span><span class="token number">1</span>/<span class="token punctuation">\</span><span class="token number">1</span>/              <span class="token comment"># 删除重复行</span>
</span><span class="code-line">:%s/<span class="token operator">&#x3C;</span><span class="token punctuation">\</span>/<span class="token punctuation">\</span><span class="token operator">=</span><span class="token punctuation">\</span><span class="token punctuation">(</span><span class="token punctuation">\</span>w<span class="token punctuation">\</span>+<span class="token punctuation">\</span><span class="token punctuation">)</span><span class="token punctuation">\</span><span class="token operator">></span>/<span class="token punctuation">\</span>U<span class="token operator">&#x26;</span>/g        <span class="token comment"># 将 HTML 标记转换为大写</span>
</span><span class="code-line">:g/^pattern/s/$/mytext           <span class="token comment"># 查找文本并将其附加到末尾</span>
</span><span class="code-line">:g/pattern/norm<span class="token operator">!</span> @i              <span class="token comment"># 在匹配行上运行宏</span>
</span><span class="code-line">/^<span class="token punctuation">\</span><span class="token punctuation">(</span>.*<span class="token punctuation">\</span><span class="token punctuation">)</span><span class="token punctuation">\</span><span class="token punctuation">(</span><span class="token punctuation">\</span>r<span class="token punctuation">\</span>?<span class="token punctuation">\</span>n<span class="token punctuation">\</span><span class="token number">1</span><span class="token punctuation">\</span><span class="token punctuation">)</span><span class="token punctuation">\</span>+$          <span class="token comment"># 查看重复行</span>
</span><span class="code-line">/<span class="token punctuation">\</span>v^<span class="token punctuation">(</span>.*<span class="token punctuation">)</span><span class="token punctuation">(</span><span class="token punctuation">\</span>r?<span class="token punctuation">\</span>n<span class="token punctuation">\</span><span class="token number">1</span><span class="token punctuation">)</span>+$              <span class="token comment"># 查看重复行（非常神奇）</span>
</span><span class="code-line">:v/./,/./-j                      <span class="token comment"># 将空行压缩成空行</span>
</span><span class="code-line">:g/<span class="token operator">&#x3C;</span>p<span class="token operator"><span class="token file-descriptor important">1</span>></span>/,/<span class="token operator">&#x3C;</span>p<span class="token operator"><span class="token file-descriptor important">2</span>></span>/d                 <span class="token comment"># 从 &#x3C;p1> 到 &#x3C;p2> 包含删除</span>
</span></code></pre>
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="vimdiff"><a aria-hidden="true" tabindex="-1" href="#vimdiff"><span class="icon icon-link"></span></a>Vimdiff</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 style="background:#d7a100;" id="用法-2"><a aria-hidden="true" tabindex="-1" href="#用法-2"><span class="icon icon-link"></span></a>用法</h3><div class="wrap-body">
<!--rehype:style=background:#d7a100;-->
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">$ vimdiff file1 file2 <span class="token punctuation">[</span>file3<span class="token punctuation">]</span>
</span><span class="code-line">$ <span class="token function">vim</span> <span class="token parameter variable">-d</span> file1 file2 <span class="token punctuation">[</span>file3<span class="token punctuation">]</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="编辑"><a aria-hidden="true" tabindex="-1" href="#编辑"><span class="icon icon-link"></span></a>编辑</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->
<pre><code class="code-highlight"><span class="code-line">:[range]diffget [bufspec]
</span><span class="code-line">:[range]diffput [bufspec]
</span></code></pre>
<hr>

































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>do</code> <em>/</em> <code>:diffget</code></td><td>获取（get）差异</td></tr><tr><td align="left"><code>dp</code> <em>/</em> <code>:diffput</code></td><td>放差价</td></tr><tr><td align="left"><code>:dif</code></td><td>重新扫描差异</td></tr><tr><td align="left"><code>:diffo</code></td><td>关闭差异模式</td></tr><tr><td align="left"><code>:1,$+1diffget</code></td><td>获取所有差异</td></tr><tr><td align="left"><code>ZQ</code></td><td>不做改动就退出</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<p>请参阅：<a href="#%E8%8C%83%E5%9B%B4">范围</a></p>
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="折叠"><a aria-hidden="true" tabindex="-1" href="#折叠"><span class="icon icon-link"></span></a>折叠</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->













































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>zo</code> <em>/</em> <code>zO</code></td><td>打开</td></tr><tr><td align="left"><code>zc</code> <em>/</em> <code>zC</code></td><td>关</td></tr><tr><td align="left"><code>za</code> <em>/</em> <code>zA</code></td><td>切换</td></tr><tr><td align="left"><code>zv</code></td><td>这条线的打开折叠</td></tr><tr><td align="left"><code>zM</code></td><td>关闭所有</td></tr><tr><td align="left"><code>zR</code></td><td>打开所有</td></tr><tr><td align="left"><code>zm</code></td><td>折叠更多 <em>(折叠级别 += 1)</em></td></tr><tr><td align="left"><code>zr</code></td><td>少折叠 <em>(折叠级别 -= 1)</em></td></tr><tr><td align="left"><code>zx</code></td><td>更新折叠</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="跳跃"><a aria-hidden="true" tabindex="-1" href="#跳跃"><span class="icon icon-link"></span></a>跳跃</h3><div class="wrap-body">

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>]c</code></td><td>下一个区别</td></tr><tr><td align="left"><code>[c</code></td><td>以前的区别</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="各种各样的"><a aria-hidden="true" tabindex="-1" href="#各种各样的"><span class="icon icon-link"></span></a>各种各样的</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="case"><a aria-hidden="true" tabindex="-1" href="#case"><span class="icon icon-link"></span></a>Case</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->

























































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>vU</code></td><td><em>大写</em> 字母</td></tr><tr><td align="left"><code>vu</code></td><td><em>小写</em> 字符</td></tr><tr><td align="left"><code>~</code></td><td><em>切换案例</em> 字符</td></tr><tr><td align="left"><code>viw</code> <code>U</code></td><td><em>大写</em> 字</td></tr><tr><td align="left"><code>viw</code> <code>u</code></td><td><em>小写</em> 字</td></tr><tr><td align="left"><code>viw</code> <code>~</code></td><td><em>切换案例</em> 字</td></tr><tr><td align="left"><code>VU</code> <em>/</em> <code>gUU</code></td><td><em>大写</em> 行</td></tr><tr><td align="left"><code>Vu</code> <em>/</em> <code>guu</code></td><td><em>小写</em> 行</td></tr><tr><td align="left"><code>V~</code> <em>/</em> <code>g~~</code></td><td><em>切换案例</em> 线</td></tr><tr><td align="left"><code>gggUG</code></td><td><em>大写</em> 所有文本</td></tr><tr><td align="left"><code>ggguG</code></td><td><em>小写</em> 所有文本</td></tr><tr><td align="left"><code>ggg~G</code></td><td><em>切换大小写</em> 所有文本</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="跳跃-1"><a aria-hidden="true" tabindex="-1" href="#跳跃-1"><span class="icon icon-link"></span></a>跳跃</h3><div class="wrap-body">

























<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>&#x3C;C-o></code></td><td>返回上一个</td></tr><tr><td align="left"><code>&#x3C;C-i></code></td><td>向前</td></tr><tr><td align="left"><code>gf</code></td><td>转到光标中的文件</td></tr><tr><td align="left"><code>ga</code></td><td>显示十六进制、ASCII值</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist row-span-2"><div class="wrap-header h3wrap"><h3 id="其他命令行"><a aria-hidden="true" tabindex="-1" href="#其他命令行"><span class="icon icon-link"></span></a>其他命令行</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2-->













































<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:h</code></td><td>帮助打开帮助视图</td></tr><tr><td align="left"><code>:edit!</code></td><td>重新加载当前文件</td></tr><tr><td align="left"><code>:2,8m0</code></td><td>将行 <code>2</code>-<code>8</code> 移动到 <code>0</code></td></tr><tr><td align="left"><code>:noh</code></td><td>清除搜索亮点</td></tr><tr><td align="left"><code>:sort</code></td><td>排序行</td></tr><tr><td align="left"><code>:ter</code></td><td>打开终端窗口</td></tr><tr><td align="left"><code>:set paste</code></td><td>启用插入粘贴子模式</td></tr><tr><td align="left"><code>:set nopaste</code></td><td>禁用插入粘贴子模式</td></tr><tr><td align="left"><code>:cq</code></td><td>退出并出现错误<br> <em>(正在中止 Git)</em></td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="导航"><a aria-hidden="true" tabindex="-1" href="#导航"><span class="icon icon-link"></span></a>导航</h3><div class="wrap-body">





























<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>%</code></td><td>最近/匹配的<code>{[()]}</code></td></tr><tr><td align="left"><code>[(</code> <em>|</em> <code>[{</code></td><td>上一个 <code>(</code> 或 <code>{</code></td></tr><tr><td align="left"><code>])</code> <em>|</em> <code>]{</code></td><td>下一个<code>)</code>或<code>}</code></td></tr><tr><td align="left"><code>[m</code></td><td>上一个方法开始</td></tr><tr><td align="left"><code>[M</code></td><td>上一个方法结束</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="计数器"><a aria-hidden="true" tabindex="-1" href="#计数器"><span class="icon icon-link"></span></a>计数器</h3><div class="wrap-body">

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>&#x3C;C-a></code></td><td>增加数量</td></tr><tr><td align="left"><code>&#x3C;C-x></code></td><td>减少数量</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist row-span-2 col-span-2"><div class="wrap-header h3wrap"><h3 id="选项卡-1"><a aria-hidden="true" tabindex="-1" href="#选项卡-1"><span class="icon icon-link"></span></a>选项卡</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-2 col-span-2-->





































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>:tag Classname</code></td><td>跳转到 Classname 的第一个定义</td></tr><tr><td align="left"><code>&#x3C;C-]></code></td><td>跳转到定义</td></tr><tr><td align="left"><code>g]</code></td><td>查看所有定义</td></tr><tr><td align="left"><code>&#x3C;C-t></code></td><td>回到最后一个标签</td></tr><tr><td align="left"><code>&#x3C;C-o> &#x3C;C-i></code></td><td>后退前进</td></tr><tr><td align="left"><code>:tselect Classname</code></td><td>查找类名的定义</td></tr><tr><td align="left"><code>:tjump Classname</code></td><td>查找类名的定义 <em>(自动选择第一个)</em></td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="格式化"><a aria-hidden="true" tabindex="-1" href="#格式化"><span class="icon icon-link"></span></a>格式化</h3><div class="wrap-body">





















<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:ce 8</code></td><td><code>8</code> 列之间的中心线</td></tr><tr><td align="left"><code>:ri 4</code></td><td>在 <code>4</code> 列右对齐行</td></tr><tr><td align="left"><code>:le</code></td><td>左对齐线</td></tr></tbody></table>
<p>查看 <code>:help formatting</code></p>
</div></div></div><div class="wrap h3body-not-exist row-span-4 col-span-2"><div class="wrap-header h3wrap"><h3 id="标记"><a aria-hidden="true" tabindex="-1" href="#标记"><span class="icon icon-link"></span></a>标记</h3><div class="wrap-body">
<!--rehype:wrap-class=row-span-4 col-span-2-->





























































































<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>`^</code></td><td>插入模式下光标的最后位置</td></tr><tr><td align="left"><code>`.</code></td><td>当前缓冲区的最后更改</td></tr><tr><td align="left"><code>`"</code></td><td>最后退出的当前缓冲区</td></tr><tr><td align="left"><code>`0</code></td><td>在上次编辑的文件中</td></tr><tr><td align="left"><code>''</code></td><td>返回当前缓冲区中跳出的行</td></tr><tr><td align="left"><code>``</code></td><td>返回当前缓冲区中跳转的位置</td></tr><tr><td align="left"><code>`[</code></td><td>到先前更改或拉出的文本的开头</td></tr><tr><td align="left"><code>`]</code></td><td>到之前更改或拉出的文本的结尾</td></tr><tr><td align="left"><code>`&#x3C;</code></td><td>到最后一个可视化选择的开始</td></tr><tr><td align="left"><code>`></code></td><td>到最后一个可视化选择的结尾</td></tr><tr><td align="left"><code>ma</code></td><td>将此光标位置标记为<code>a</code></td></tr><tr><td align="left"><code>`a</code></td><td>跳转到光标位置<code>a</code></td></tr><tr><td align="left"><code>'a</code></td><td>跳转到位置为 <code>a</code> 的行首</td></tr><tr><td align="left"><code>d'a</code></td><td>从当前行删除到标记 <code>a</code> 的行</td></tr><tr><td align="left"><code>d`a</code></td><td>从当前位置删除到标记 <code>a</code> 的位置</td></tr><tr><td align="left"><code>c'a</code></td><td>将文本从当前行更改为 <code>a</code> 行</td></tr><tr><td align="left"><code>y`a</code></td><td>将文本从当前位置拉到 <code>a</code> 的位置</td></tr><tr><td align="left"><code>:marks</code></td><td>列出所有当前标记</td></tr><tr><td align="left"><code>:delm a</code></td><td>删除标记<code>a</code></td></tr><tr><td align="left"><code>:delm a-d</code></td><td>删除标记<code>a</code>、<code>b</code>、<code>c</code>、<code>d</code></td></tr><tr><td align="left"><code>:delm abc</code></td><td>删除标记<code>a</code>、<code>b</code>、<code>c</code></td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="计算器"><a aria-hidden="true" tabindex="-1" href="#计算器"><span class="icon icon-link"></span></a>计算器</h3><div class="wrap-body">

















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>&#x3C;C-r></code> <code>=</code> 7*7</td><td>显示结果</td></tr><tr><td align="left"><code>&#x3C;C-r></code> <code>=</code> 10/2</td><td>显示结果</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
<p>在 INSERT 模式下执行此操作</p>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="shell"><a aria-hidden="true" tabindex="-1" href="#shell"><span class="icon icon-link"></span></a>Shell</h3><div class="wrap-body">

























<table><thead><tr><th align="left">:-</th><th>-</th></tr></thead><tbody><tr><td align="left"><code>:!&#x3C;shell></code></td><td>解释 Shell 命令</td></tr><tr><td align="left"><code>:r!&#x3C;shell></code></td><td>读入shell的输出</td></tr><tr><td align="left"><code>:r!date</code></td><td>插入日期</td></tr><tr><td align="left"><code>:!!date</code></td><td>用日期替换当前行</td></tr></tbody></table>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="命令行"><a aria-hidden="true" tabindex="-1" href="#命令行"><span class="icon icon-link"></span></a>命令行</h3><div class="wrap-body">





















<table class="shortcuts"><thead><tr><th align="left">快捷方式</th><th>说明</th></tr></thead><tbody><tr><td align="left"><code>&#x3C;C-r>&#x3C;C-w></code></td><td>将当前单词插入命令行</td></tr><tr><td align="left"><code>&#x3C;C-r>"</code></td><td>从 <code>注册</code> 粘贴</td></tr><tr><td align="left"><code>&#x3C;C-x>&#x3C;C-f></code></td><td>在插入模式下自动完成路径</td></tr></tbody></table>
<!--rehype:className=shortcuts-->
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="技巧"><a aria-hidden="true" tabindex="-1" href="#技巧"><span class="icon icon-link"></span></a>技巧</h3><div class="wrap-body">
<p>删除重复行</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">:sort <span class="token operator">|</span> %<span class="token operator">!</span>uniq <span class="token parameter variable">-u</span>
</span></code></pre>
<p>对文件中的行进行编号</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">:%<span class="token operator">!</span>cat <span class="token parameter variable">-n</span>
</span></code></pre>
<p>将整个文档复制到剪贴板</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">:%w <span class="token operator">!</span>pbcopy            <span class="token comment"># Mac OS X</span>
</span><span class="code-line">:%w <span class="token operator">!</span>xclip <span class="token parameter variable">-i</span> <span class="token parameter variable">-sel</span> c   <span class="token comment"># GNU/Linux</span>
</span><span class="code-line">:%w <span class="token operator">!</span>xsel <span class="token parameter variable">-i</span> <span class="token parameter variable">-b</span>        <span class="token comment"># GNU/Linux</span>
</span></code></pre>
</div></div></div></div></div><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="理解-vim"><a aria-hidden="true" tabindex="-1" href="#理解-vim"><span class="icon icon-link"></span></a>理解 Vim</h2><div class="wrap-body">
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="动词理解"><a aria-hidden="true" tabindex="-1" href="#动词理解"><span class="icon icon-link"></span></a>动词理解</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">d  <span class="token comment"># 表示删除delete</span>
</span><span class="code-line">r  <span class="token comment"># 表示替换replace</span>
</span><span class="code-line">c  <span class="token comment"># 表示修改change</span>
</span><span class="code-line">y  <span class="token comment"># 表示复制yank</span>
</span><span class="code-line"><span class="token function">v</span>  <span class="token comment"># 表示选取visual select</span>
</span></code></pre>
<p>动词代表了我们打算对文本进行什么样的操作</p>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="名词理解"><a aria-hidden="true" tabindex="-1" href="#名词理解"><span class="icon icon-link"></span></a>名词理解</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">w  <span class="token comment"># 表示一个单词word</span>
</span><span class="code-line">s  <span class="token comment"># 表示一个句子sentence</span>
</span><span class="code-line">p  <span class="token comment"># 表示一个段落paragraph</span>
</span><span class="code-line">t  <span class="token comment"># 表示一个 HTML 标签tag</span>
</span></code></pre>
<p>名词代表了我们即将处理的文本。引号或者各种括号所包含的文本称作一个文本块。</p>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="介词理解"><a aria-hidden="true" tabindex="-1" href="#介词理解"><span class="icon icon-link"></span></a>介词理解</h3><div class="wrap-body">
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">i  <span class="token comment"># 表示在...之内 inside</span>
</span><span class="code-line">a  <span class="token comment"># 表示环绕... around</span>
</span><span class="code-line">t  <span class="token comment"># 表示到...位置前 to</span>
</span><span class="code-line">f  <span class="token comment"># 表示到...位置上 forward</span>
</span></code></pre>
<p>介词界定了待编辑文本的范围或者位置。</p>
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="数词理解"><a aria-hidden="true" tabindex="-1" href="#数词理解"><span class="icon icon-link"></span></a>数词理解</h3><div class="wrap-body">
<!--rehype:wrap-class=col-span-2-->
<p>数词指定了待编辑文本对象的数量，从这个角度而言，数词也可以看作是一种介词。引入数词之后，文本编辑命令的语法就升级成了下面这样：</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">动词 介词/数词 名词
</span></code></pre>
<p>下面是几个例子：</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">c3w  <span class="token comment"># 修改三个单词：change three words</span>
</span><span class="code-line">d2w  <span class="token comment"># 删除两个单词：delete two words</span>
</span></code></pre>
<p>另外，数词也可以修饰动词，表示将操作执行 <code>n</code> 次。于是，我们又有了下面的语法：</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">数词 动词 名词
</span></code></pre>
<p>示例</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">2dw <span class="token comment"># 两次删除单词(等价于删除两个单词): twice delete word</span>
</span><span class="code-line">3x  <span class="token comment"># 三次删除字符(等价于删除三个字符): three times delete character</span>
</span></code></pre>
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="组词为句理解"><a aria-hidden="true" tabindex="-1" href="#组词为句理解"><span class="icon icon-link"></span></a>组词为句理解</h3><div class="wrap-body">
<p>有了这些基本的语言元素，我们就可以着手构造一些简单的命令了。文本编辑命令的基本语法如下：</p>
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line">动词 介词 名词
</span></code></pre>
<p>下面是一些例子</p>
<pre class="wrap-text "><code class="language-shell code-highlight"><span class="code-line">dip <span class="token comment"># 删除一个段落: delete inside paragraph</span>
</span><span class="code-line">vis <span class="token comment"># 选取一个句子: visual select inside sentence</span>
</span><span class="code-line">ciw <span class="token comment"># 修改一个单词: change inside word</span>
</span><span class="code-line">caw <span class="token comment"># 修改一个单词: change around word</span>
</span><span class="code-line">dtx <span class="token comment"># 删除文本直到字符“x”(不包括字符“x”): delete to x</span>
</span><span class="code-line">dfx <span class="token comment"># 删除文本直到字符“x”(包括字符“x”): delete forward x</span>
</span></code></pre>
<!--rehype:className=wrap-text -->
</div></div></div></div></div><div class="wrap h2body-not-exist"><div class="wrap-header h2wrap"><h2 id="另见"><a aria-hidden="true" tabindex="-1" href="#另见"><span class="icon icon-link"></span></a>另见</h2><div class="wrap-body">
<ul>
<li><a href="https://jaywcjlove.github.io/vim-web">搞得像IDE一样的 Vim</a> <em>(github.io)</em></li>
<li><a href="http://www.vim.org/">Vim 官方网站</a> <em>(vim.org)</em></li>
<li><a href="https://devhints.io/vim">Devhints</a> <em>(devhints.io)</em></li>
<li><a href="https://vim.rtorr.com/lang/zh_cn/">Vim cheatsheet</a> <em>(vim.rotrr.com)</em></li>
<li><a href="http://vimdoc.sourceforge.net/htmldoc/">Vim documentation</a> <em>(vimdoc.sourceforge.net)</em></li>
<li><a href="http://openvim.com/">Interactive Vim tutorial</a> <em>(openvim.com)</em></li>
</ul>
</div></div><div class="h2wrap-body"></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang.</footer></footer><script src="..\/data.js?v=1.4.1" defer></script><script src="..\/js/fuse.min.js?v=1.4.1" defer></script><script src="..\/js/main.js?v=1.4.1" defer></script><div id="mysearch"><div class="mysearch-box"><div class="mysearch-input"><div><svg xmlns="http://www.w3.org/2000/svg" height="1em" width="1em" viewBox="0 0 18 18">
  <path fill="currentColor" d="M17.71,16.29 L14.31,12.9 C15.4069846,11.5024547 16.0022094,9.77665502 16,8 C16,3.581722 12.418278,0 8,0 C3.581722,0 0,3.581722 0,8 C0,12.418278 3.581722,16 8,16 C9.77665502,16.0022094 11.5024547,15.4069846 12.9,14.31 L16.29,17.71 C16.4777666,17.8993127 16.7333625,18.0057983 17,18.0057983 C17.2666375,18.0057983 17.5222334,17.8993127 17.71,17.71 C17.8993127,17.5222334 18.0057983,17.2666375 18.0057983,17 C18.0057983,16.7333625 17.8993127,16.4777666 17.71,16.29 Z M2,8 C2,4.6862915 4.6862915,2 8,2 C11.3137085,2 14,4.6862915 14,8 C14,11.3137085 11.3137085,14 8,14 C4.6862915,14 2,11.3137085 2,8 Z"></path>
</svg><input id="mysearch-input" type="search" placeholder="搜索" autocomplete="off"><div class="mysearch-clear"></div></div><button id="mysearch-close" type="button">搜索</button></div><div class="mysearch-result"><div id="mysearch-menu"></div><div id="mysearch-content"></div></div></div></div></body>
</html>
